package cn.cloudtogo.server;

import cn.cloudtogo.common.types.Result;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

/**
 * @author yaolianhua789@gmail.com
 **/
public final class WebResponse {
    private WebResponse() {
    }

    public static <T> ResponseEntity<Result<Void>> none() {
        return none(HttpStatus.OK);
    }

    public static <T> ResponseEntity<Result<Void>> none(HttpStatus status) {
        return ResponseEntity.status(status).body(Result.of());
    }

    public static <T> ResponseEntity<Result<T>> ok(T data) {
        return ok(HttpStatus.OK, data);
    }


    public static <T> ResponseEntity<Result<T>> ok(HttpStatus status, T data) {
        return ResponseEntity.status(status).body(Result.of(data));
    }

    public static <T> ResponseEntity<Result<T>> created(T data) {
        return ResponseEntity.status(HttpStatus.CREATED).body(Result.of(data));
    }

    public static <T> ResponseEntity<Result<T>> created() {
        return created(null);
    }

    public static <T> ResponseEntity<Result<T>> accepted(T data) {
        return ResponseEntity.accepted().body(Result.of(data));
    }

    public static <T> ResponseEntity<Result<T>> accepted() {
        return accepted(null);
    }

}
